home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2003 July / CD 2 Debian 3.0r1 / Debian.iso / install / doc / fdisk.txt < prev    next >
Encoding:
Text File  |  2002-05-18  |  9.7 KB  |  218 lines

  1. FDISK(8)        Linux Programmer's Manual         FDISK(8)
  2.  
  3.  
  4.  
  5. NAME
  6.        fdisk - Partition table manipulator for Linux
  7.  
  8. SYNOPSIS
  9.        fdisk [-u] [-b sectorsize]device
  10.  
  11.        fdisk -l [-u] [-b sectorsize] [device ...]
  12.  
  13.        fdisk -s partition ...
  14.  
  15.        fdisk -v
  16.  
  17. DESCRIPTION
  18.        Hard  disks  can be divided into one or more logical disks
  19.        called partitions.  This division is described in the par_
  20.        tition table found in sector 0 of the disk.
  21.  
  22.        In  the    BSD  world  one  talks    about `disk slices' and a
  23.        `disklabel'.
  24.  
  25.        Linux needs at least one partition, namely  for    its  root
  26.        file  system.   It  can    use swap files and/or swap parti
  27.        tions, but the latter are more efficient. So, usually  one
  28.        will  want a second Linux partition dedicated as swap par
  29.        tition.    On Intel compatible hardware, the BIOS that boots
  30.        the  system can often only access the first 1024 cylinders
  31.        of the disk.  For this  reason  people  with  large  disks
  32.        often create a third partition, just a few MB large, typi
  33.        cally mounted on /boot, to store the kernel  image  and    a
  34.        few  auxiliary  files  needed  at boot time, so as to make
  35.        sure that this stuff is accessible to the BIOS.    There may
  36.        be reasons of security, ease of administration and backup,
  37.        or testing, to use more than the minimum number of  parti
  38.        tions.
  39.  
  40.        fdisk  (in  the first form of invocation) is a menu driven
  41.        program for creation and manipulation of partition tables.
  42.        It  understands    DOS  type partition tables and BSD or SUN
  43.        type disklabels.
  44.  
  45.        The device is usually one of the following:
  46.           /dev/hda
  47.           /dev/hdb
  48.           /dev/sda
  49.           /dev/sdb
  50.        (/dev/hd[a-h] for IDE disks, /dev/sd[a-p] for SCSI  disks,
  51.        /dev/ed[a-d] for ESDI disks, /dev/xd[ab] for XT disks).    A
  52.        device name refers to the entire disk.
  53.  
  54.        The partition is a device name  followed  by  a    partition
  55.        number.     For example, /dev/hda1 is the first partition on
  56.        the first IDE hard disk in the system.  IDE disks can have
  57.        up  to  63  partitions,    SCSI  disks  up  to 15.  See also
  58.        /usr/src/linux/Documentation/devices.txt.
  59.  
  60.        A BSD/SUN type disklabel can describe  8  partitions,  the
  61.        third of which should be a `whole disk' partition.  Do not
  62.        start a partition that  actually  uses  its  first  sector
  63.        (like  a  swap  partition)  at cylinder 0, since that will
  64.        destroy the disklabel.
  65.  
  66.        An IRIX/SGI type disklabel can describe 16 partitions, the
  67.        eleventh  of which should be an entire `volume' partition,
  68.        while the ninth should be labeled  `volume  header'.   The
  69.        volume  header  will also cover the partition table, i.e.,
  70.        it starts at block zero and extends by default  over  five
  71.        cylinders.   The  remaining space in the volume header may
  72.        be used by header directory entries.   No  partitions  may
  73.        overlap    with  the  volume header.  Also do not change its
  74.        type and make some file system on it, since you will  lose
  75.        the  partition  table.    Use  this type of label only when
  76.        working with Linux on IRIX/SGI machines or IRIX/SGI  disks
  77.        under Linux.
  78.  
  79.        A  DOS type partition table can describe an unlimited num
  80.        ber of partitions. In sector  0    there  is  room  for  the
  81.        description  of    4  partitions  (called `primary'). One of
  82.        these may be an extended partition; this is a box  holding
  83.        logical    partitions,  with  descriptors    found in a linked
  84.        list of sectors, each preceding the corresponding  logical
  85.        partitions.   The four primary partitions, present or not,
  86.        get numbers 1-4.  Logical partitions start numbering  from
  87.        5.
  88.  
  89.        In  a DOS type partition table the starting offset and the
  90.        size of each partition is stored in two ways: as an  abso
  91.        lute  number of sectors (given in 32 bits) and as a Cylin
  92.        ders/Heads/Sectors triple (given in 10+8+6 bits). The for
  93.        mer  is    OK - with 512-byte sectors this will work up to 2
  94.        TB. The latter has two different problems. First  of  all,
  95.        these  C/H/S  fields can be filled only when the number of
  96.        heads and the number of sectors per track are known.  Sec
  97.        ondly,  even  if we know what these numbers should be, the
  98.        24 bits that are available do not suffice.  DOS uses C/H/S
  99.        only, Windows uses both, Linux never uses C/H/S.
  100.  
  101.        If possible, fdisk will obtain the disk geometry automati
  102.        cally.  This is not necessarily the physical disk geometry
  103.        (indeed,  modern  disks do not really have anything like a
  104.        physical geometry, certainly not  something  that  can  be
  105.        described in simplistic Cylinders/Heads/Sectors form), but
  106.        is the disk geometry that MS-DOS uses  for  the    partition
  107.        table.
  108.  
  109.        Usually    all  goes well by default, and there are no prob
  110.        lems if Linux is the only system on the disk. However,  if
  111.        the disk has to be shared with other operating systems, it
  112.        is often a good idea to let an fdisk from another  operat
  113.        ing  system  make at least one partition. When Linux boots
  114.        it looks at the partition table, and tries to deduce  what
  115.        (fake)  geometry  is  required  for  good cooperation with
  116.        other systems.
  117.  
  118.        Whenever a partition table is printed out,  a  consistency
  119.        check  is  performed on the partition table entries.  This
  120.        check verifies that the physical and logical start and end
  121.        points  are  identical,    and that the partition starts and
  122.        ends on a cylinder boundary (except for the  first  parti
  123.        tion).
  124.  
  125.        Some  versions  of  MS-DOS  create a first partition which
  126.        does not begin on a cylinder boundary, but on sector 2  of
  127.        the  first  cylinder.   Partitions beginning in cylinder 1
  128.        cannot begin on a cylinder boundary, but this is  unlikely
  129.        to  cause difficulty unless you have OS/2 on your machine.
  130.  
  131.        A sync() and a BLKRRPART ioctl() (reread  partition  table
  132.        from disk) are performed before exiting when the partition
  133.        table has been updated.    Long ago it used to be    necessary
  134.        to  reboot after the use of fdisk.  I do not think this is
  135.        the case anymore - indeed,  rebooting  too  quickly  might
  136.        cause  loss  of    not-yet-written  data. Note that both the
  137.        kernel and the disk hardware may buffer data.
  138.  
  139.  
  140. DOS 6.x WARNING
  141.        The DOS 6.x FORMAT command looks for some  information  in
  142.        the  first  sector  of the data area of the partition, and
  143.        treats this information as more reliable than the informa
  144.        tion in the partition table.  DOS FORMAT expects DOS FDISK
  145.        to clear the first 512 bytes of the data area of a  parti
  146.        tion  whenever a size change occurs.  DOS FORMAT will look
  147.        at this extra information even if the /U flag is given  --
  148.        we consider this a bug in DOS FORMAT and DOS FDISK.
  149.  
  150.        The  bottom  line  is  that  if you use cfdisk or fdisk to
  151.        change the size of a DOS partition table entry,    then  you
  152.        must  also use dd to zero the first 512 bytes of that par
  153.        tition before using DOS FORMAT to  format  the  partition.
  154.        For example, if you were using cfdisk to make a DOS parti
  155.        tion table entry for /dev/hda1, then (after exiting  fdisk
  156.        or  cfdisk and rebooting Linux so that the partition table
  157.        information is  valid)  you  would  use    the  command  "dd
  158.        if=/dev/zero  of=/dev/hda1  bs=512  count=1"  to  zero the
  159.        first 512 bytes of the partition.
  160.  
  161.        BE EXTREMELY CAREFUL if you use the dd  command,  since    a
  162.        small  typo can make all of the data on your disk useless.
  163.  
  164.        For best results, you should  always  use  an  OS-specific
  165.        partition table program.  For example, you should make DOS
  166.        partitions with the DOS FDISK program and Linux partitions
  167.        with the Linux fdisk or Linux cfdisk program.
  168.  
  169.  
  170. OPTIONS
  171.        -b sectorsize
  172.           Specify  the  sector size of the disk. Valid values
  173.           are 512, 1024, or 2048.  (Recent kernels    know  the
  174.           sector  size.  Use  this    only on old kernels or to
  175.           override the kernel's ideas.)
  176.  
  177.        -l     List the partition tables for the specified devices
  178.           and then exit.  If no devices are given, those men
  179.           tioned in /proc/partitions  (if  that  exists)  are
  180.           used.
  181.  
  182.        -u     When  listing  partition tables, give sizes in sec
  183.           tors instead of cylinders.
  184.  
  185.        -s partition
  186.           The size of the partition (in blocks) is printed on
  187.           the standard output.
  188.  
  189.        -v     Print version number of fdisk program and exit.
  190.  
  191. BUGS
  192.        There  are  several  *fdisk programs around.  Each has its
  193.        problems and strengths.    Try them  in  the  order  cfdisk,
  194.        fdisk,  sfdisk.     (Indeed,  cfdisk  is a beautiful program
  195.        that has strict requirements on the  partition  tables  it
  196.        accepts,  and  produces high quality partition tables. Use
  197.        it if you can.  fdisk is a buggy program that  does  fuzzy
  198.        things - usually it happens to produce reasonable results.
  199.        Its single advantage is that it has some support  for  BSD
  200.        disk  labels and other non-DOS partition tables.  Avoid it
  201.        if you can.  sfdisk is for hackers only - the user  inter
  202.        face  is  terrible,  but it is more correct than fdisk and
  203.        more powerful than both fdisk and  cfdisk.   Moreover,  it
  204.        can be used noninteractively.)
  205.  
  206.        The  IRIX/SGI type disklabel is currently not supported by
  207.        the kernel.  Moreover, IRIX/SGI header directories are not
  208.        fully supported yet.
  209.  
  210.        The option `dump partition table to file' is missing.
  211.  
  212. SEE ALSO
  213.        cfdisk(8), parted(8), sfdisk(8)
  214.  
  215.  
  216.  
  217. Linux 2.0           11 June 1998          FDISK(8)
  218.